package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.model.user.UserAddress;
import com.atguigu.gmall.order.client.OrderFeignClient;
import com.atguigu.gmall.user.client.UserFeignClient;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
public class OrderController {

    @Resource
    private OrderFeignClient orderFeignClient;
    @Resource
    private UserFeignClient userFeignClient;

    @GetMapping("trade.html")
    public String trade(Model model){
        //查询页面上显示的信息
        //用户收货地址：用户微服务获取
        List<UserAddress> userAddressesList = userFeignClient.getUserAddressList();
        model.addAttribute("userAddressList",userAddressesList);
        //商品清单
        Map<String,Object> trade = orderFeignClient.trade();//k为detailArrayList，v为orderDetailList
        model.addAllAttributes(trade);
        return "order/trade";
    }

}
